<?php


namespace App\Http\Controllers\Admin;
use App\Http\Controllers\BaseController;
use App\Models\News;
use Illuminate\Http\Request;

class NewsController extends BaseController
{
    protected $model = News::class;

    /**
     * 列表
     * @param Request $request
     * @return mixed
     */
    public function index(Request $request) {
        $input = $request->input();
        $search = ['title' => '', 'category_id' => '', 'start_at' => '', 'end_at' => '', 'on_status' => -1];
        $list = News::apply($search, $input)
            ->withCertain('category', ['title'])
            ->orderBy("sort", "desc")->orderBy("id", "desc")
            ->paginate(per_page());
        return $this->paginate($list);
    }

}

